<!--管家服务考核管理查看结果-->
<template>
  <el-dialog title="管家服务考核结果查看" :close-on-click-modal="false" :visible.sync="messageShow">
    <el-main>
      <div>{{this.totalStatistic.quarterTimeTitle}} <span style="color: #0000cc">{{ totalStatistic.quarterTime }}</span></div>
      <div style="margin-top: 10px">{{this.totalStatistic.avgWholeScoreTitle}} <span style="color: #0000cc">{{ parseInt(totalStatistic.avgWholeScore)===0?"——":totalStatistic.avgWholeScore }}</span></div>
      <div style="margin-top: 10px">价值观考核结果等级：<span style="color: #0000cc">{{ totalStatistic.subordinateGrade }}</span></div>
      <div style="font-size: larger;margin-top: 30px">下级评价结果</div>

      <el-row v-for="item in dataList" v-loading="dataListLoading" :gutter="50" style="margin-top: 30px; border-bottom: 1px solid #C5C5C5 ">
        <el-col :span="4" style="text-align: center">

          <div><img :src = 'item.avatar' alt=""
                    style="width: 50px; "></div>
          <div><span class="grid-content bg-purple">{{item.nickname}}</span></div>
          <div><span class="phoneSpan">{{item.phone}}</span></div>

          <div v-if="item.isComment===0" style="margin-top: 30px;margin-bottom: 30px"><span>未评价</span></div>

        </el-col>
        <el-col :span="18">
          <div>整体评分：<span style="color: #0000cc;">{{(item.isComment===0 && isShow)?"":item.wholeScore }}</span></div>
          <div style="margin-top: 15px">评价评分：<span style="color: #0000cc;">{{(item.isComment===0 && isShow)?"":item.teachingScore }}</span></div>
          <div style="margin-top: 15px">沟通情况评分：<span style="color: #0000cc;">{{(item.isComment===0 && isShow)?"":item.communicationScore }}</span></div>

          <div v-if="(item.evaluationSuperiorDescribe || item.evaluationSuperiorImg) " style="font-size: larger; margin-top: 30px">评分举例说明汇总</div>
          <div style="margin-top: 15px">{{ item.evaluationSuperiorDescribe }}</div>
          <div style="margin-top: 15px" class="imgContent" v-html="imgHandle(item.evaluationSuperiorImg)"></div>

        </el-col>
      </el-row>

      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper"
      ></el-pagination>

    </el-main>
    <span slot="footer" class="dialog-footer">
      <el-button @click="messageShow = false">返回</el-button>
    </span>
    <bigimg :bigimgsrc="bigsrc" v-if="showbig" @hideimg="hidebig"></bigimg>
  </el-dialog>
</template>

<script>

    import bigimg from '@/components/bigimg/index'
    export default {
        name: "housekeeperServiceViewResult",
        components: {bigimg},
        data () {
            return {
                messageShow: false,
                evaluationViewShow:false,
                id:"",
                pageIndex: 1,
                pageSize: 10,
                totalPage: 0,
                dataListLoading: false,
                isShow:true,

                form: {},
                totalStatistic: {
                    quarterTimeTitle:"",
                    quarterTime:"",
                    valueId:"",
                    title:"",
                    avgWholeScore:"",
                    avgWholeScoreTitle:"",
                    subordinateGrade:""
                },
                dataList:[],
                valueId:"",


            };
        },
        methods: {
            init (object,isShow) {

                console.log(object);

                this.totalStatistic = object;
                this.isShow = isShow;


                let dateYearStr = object.quarterTime.slice(0, 4);
                let dateMonthStr = object.quarterTime.slice(4, 6);

                if (parseInt(dateMonthStr) === 1){
                    this.totalStatistic.quarterTimeTitle = dateYearStr+"年第一季度: ";
                } else if (parseInt(dateMonthStr) === 4) {
                    this.totalStatistic.quarterTimeTitle = dateYearStr+"年第二季度: ";
                } else if (parseInt(dateMonthStr) === 7) {
                    this.totalStatistic.quarterTimeTitle = dateYearStr+"年第三季度: ";
                } else if (parseInt(dateMonthStr) === 10) {
                    this.totalStatistic.quarterTimeTitle = dateYearStr+"年第四季度: ";
                }

                this.totalStatistic.avgWholeScoreTitle = object.title + ":";

                let dateLabel = dateYearStr+"."+dateMonthStr+"-"+dateYearStr+"."+ (parseInt(dateMonthStr)+2);
                this.totalStatistic.quarterTime = dateLabel;

                switch (parseInt(object.subordinateGrade)) {
                    case 0: this.totalStatistic.subordinateGrade = "未评"; break;
                    case 1: this.totalStatistic.subordinateGrade = "优秀"; break;
                    case 2: this.totalStatistic.subordinateGrade = "良好"; break;
                    case 3: this.totalStatistic.subordinateGrade = "待提升"; break;
                    default: break;
                }


                this.form = {}
                this.messageShow = true
                this.valueId = object.valueId
                this.getDataList()

            },

            imgHandle(evaluationSuperiorImg){
                // let imgStr = "http://5b0988e595225.cdn.sohucs.com/images/20170919/e26d16f2b0de4ac9bf3894b630e05282.jpeg"
                let imgHtml = ''
                // let imgArr = [imgStr,imgStr,imgStr,imgStr]
                if(evaluationSuperiorImg){
                    evaluationSuperiorImg.map((item) => {
                        imgHtml += `<img src="${item}" style="width: 200px;height:auto;margin: 15px;" @click="setbig(item)">`
                    })
                }
                return imgHtml
            },

            // 获取数据
            getDataList() {

                this.dataListLoading = true;
                let obj = {
                    page: this.pageIndex,
                    limit: this.pageSize,
                    stewardServiceInfoId: this.valueId   // 接口需要改参数名stewardServiceInfoId
                };
                this.$http({
                    url: this.$http.adornUrl("/value/stewardservicelog/getSubordinateEvaluationResult"),
                    method: "get",
                    params: this.$http.adornParams(obj)
                }).then(({ data }) => {
                    if (data && data.code === 0) {
                        this.dataList = data.page.list;
                        this.totalPage = data.page.totalCount;
                    } else {
                        this.dataList = [];
                        this.totalPage = 0;

                    }
                    this.dataListLoading = false;
                });
            },

            // 每页数
            sizeChangeHandle(val) {
                this.pageSize = val;
                this.pageIndex = 1;
                this.getDataList();
            },
            // 当前页
            currentChangeHandle(val) {
                this.pageIndex = val;
                this.getDataList();
            },

            setbig(imgUrl) {
                this.bigsrc = imgUrl
                this.showbig = true
            },
            hidebig() {
                this.showbig = false
            },


        }
    }
</script>

<style scoped>
  /*.imgContent{*/
  /*  border: 1px solid #898989;*/
  /*  border-radius: 6px;*/
  /*  padding: 30px;*/
  /*  !*height:400px;*!*/
  /*  !*overflow-y: scroll;*!*/
  /*}*/
</style>
